package cn.heycm.blog.common.sms;

import cn.heycm.blog.common.sms.service.SmsService;
import cn.heycm.blog.common.sms.service.UniSmsServiceImpl;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * SMS 配置
 *
 * @author hey
 * @version 1.0
 * @since 2024/9/17 16:42
 */
@Configuration
@EnableConfigurationProperties(SmsProperties.class)
@ConditionalOnProperty(prefix = "sms", name = "access-key")
public class SmsAutoConfiguration {

    @Bean
    @ConditionalOnMissingBean(SmsService.class)
    public SmsService smsService(SmsProperties smsProperties) {
        return new UniSmsServiceImpl(smsProperties);
    }

}
